package net.asgarli.abalone.model;

import java.io.IOException;
import java.io.Serializable;

/**
 * Identifies the class that can be serialized and de-serialized into/from byte
 * array.
 * 
 * @author Elchin
 */
public interface Marshallable extends Serializable {

    /**
     * Writes the given class with its state to a byte array.
     * 
     * @return the byte array having the classes state.
     * @throws IOException
     *             If things go wrong.
     */
    public byte[] writeToBytes() throws IOException;

    /**
     * Restores the object and its state from byte array.
     * 
     * @param bytes
     *            the byte array having the state of the object.
     * @throws IOException
     *             If things go wrong.
     */
    public void restoreFromBytes(byte[] bytes) throws IOException;
}
